<template>
  <div>
    <h1>adsdfds</h1>
    <ul>
      <li v-for="item in dataList" :key="item.id" @click="goToDetail(item.id)">
        {{ item.text }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dataList: [
        {
          id: "001",
          text: "商品1",
        },
        {
          id: "002",
          text: "商品2",
        },
        {
          id: "003",
          text: "商品3",
        },
      ],
    };
  },
  methods: {
    goToDetail(id) {
      //   this.$router.push("/detail?id=" + id);  // query传参
      //   this.$router.push("/detail/" + id); // 动态路由
      this.$router.push({
        // 命名路由
        name: "myDetail",
        params: {
          id,
        },
      });
    },
  },
};
</script>

<style scoped>
</style>
